$(function () {
    layui.use('upload', function () {
        var upload = layui.upload;
        layui.each($(".fileBtn"),function(index, elem){
            upload.render({
                elem: elem, //绑定元素
                url:'/file/upload',
                // size: 100000,
                multiple: true,
                accept: 'file',
                done: function (respone) {
                    console.log(respone);
                    var imgid = "#"+$(elem).attr("data-img");
                    var imghidden = "#"+$(elem).attr("data-img")+"url";
                    $(imgid).attr("src", FILEROOTPATH + respone.filePath);
                    $(imghidden).val(respone.filePath);
                    layer.msg("上传成功",{
                        icon:6,
                        time:2000,
                    });
                },
                error: function (respone) {
                    layer.msg("上传失败",{
                        icon:0,
                        time:2000,
                    });
                }
            });
        });
    });





    layui.use('upload', function () {
        var upload = layui.upload;
        layui.each($(".moreFileBtn"),function(index, elem){
            upload.render({
                elem: elem, //绑定元素
                url: '/fileupload/uploadNew', //上传接口
                // size: 100000,
                multiple: true,
                accept: 'file',
                done: function (r) {
                    console.log(r);
                    var imghidden = "#"+$(elem).attr("data-img")+"url";
                    var fileName =r.filePath;
                    $(".img_upload1").append("<img id='"+fileName+"' src='"+DOMAIN+fileName+"' style='margin:10px;width:200px;height:150px' onclick='del(this)'/>");
                    $(imghidden).val($(imghidden).val()+","+fileName);
                    layer.msg(r.msg,{
                        time:2000,
                        icon:6
                    });
                },
                error: function (r) {
                    layer.msg(r.msg);
                }
            });
        });
    });


    /**
     * 上传word解析
     */
    layui.use('upload', function () {
        var upload = layui.upload;
        layui.each($(".wordBtn"),function(index, elem){
            upload.render({
                elem: elem, //绑定元素
                url: '/uploadWord', //上传接口
                // size: 100000,
                multiple: true,
                accept: 'file',
                acceptMime : '',
                exts:'',
                done: function (r) {
                    UE.getEditor('editor').setContent(r.content);
                },
                error: function (r) {
                    layer.msg("上传失败",{
                        icon:0,
                        time:2000,
                    });
                }
            });
        });
    });
})